/**
 * Created by chaoCheng on 2017/1/16.
 */

function GroupAddController(Detail,Upload,API,$http,$uibModal,$scope,$state,$stateParams){
    var vm=this;
    vm.planId=$stateParams.planId;
    vm.playgroup = {groupId:$stateParams.groupId,planId:$stateParams.planId}
    vm.addGroup=function(){
        vm.queryParams = _.clone($stateParams)
        Detail.addGroup(vm.playgroup).$promise.then(function(response){
            //处理add之后的返回结果
            if(response.success != null) {
                // 模拟窗口打开之后执行该函数
                var modalInstance = $uibModal.open({
                    templateUrl: 'myModalContent.html',
                    controller: 'ModalInstanceCtrl',
                    size: Detail
                });

                // 模拟窗口关闭后回传调用
                modalInstance.result.then(function () {
                    $state.go('detail', {'planId':$stateParams.planId})
                });
            } else {
                $scope.serverError = response.fail
            }
        })
    }

}

